package com.yangchuang.openpicture.communication;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum ResultCode {
    // 成功
    SUCCESS(200, "操作成功"),

    // JWT & 权限相关 (400-499)
    ExpiredToken(401, "AccessToken 已过期"),
    InvalidToken(402, "无效的 Token"),
    JWT_TOKEN_MISSING(403, "缺少 JWT Token"),
    PERMISSION_DENIED(405, "权限不足"),

    // 用户登录注册 (500-599)
    LOGIN_FAILED(500, "邮箱或密码错误"),
    USER_ALREADY_EXISTS(501, "用户名已存在"),
    USER_NOT_FOUND(502, "用户不存在"),
    PASSWORD_INCORRECT(503, "密码错误"),
    ACCOUNT_DISABLED(504, "账户已被禁用"),
    TOO_MANY_LOGIN_ATTEMPTS(505, "登录失败次数过多，请稍后再试"),

    // 用户邮箱相关 (600-699)
    NO_SUCH_USER(600, "邮箱未注册"),
    REPEATED_EMAIL(601, "当前邮箱已被注册"),
    EMAIL_SEND_FAILED(602, "邮件发送失败"),
    EMAIL_NOT_VERIFIED(603, "邮箱未验证"),

    // 参数问题 (700-799)
    PARAM_INVALID(700, "传入的参数不合法"),
    DIFFERENT_PASSWORD(701, "两次输入的密码不一致"),
    MISSING_REQUIRED_PARAM(702, "缺少必填参数"),

    // 验证码 (800-899)
    WRONG_CHECKCODE(800, "验证码错误"),
    VERIFICATION_CODE_EXPIRED(801, "验证码已过期"),
    VERIFICATION_TOO_FREQUENT(802, "验证码请求过于频繁"),

    // AI 相关错误 (1000-1099)
    AI_PROCESS_FAILED(1000, "AI 图片分析失败，请稍后重试"),
    AI_RESPONSE_EMPTY(1001, "AI 返回结果为空"),
    AI_RESPONSE_INVALID(1002, "AI 返回格式错误"),

    // 文件上传 (1200-1299)
    EMPTY_FILENAME(1200, "文件名不能为空"),
    FILE_UPLOAD_FAILED(1201, "文件上传失败"),
    FILE_DELETE_FAILED(1202, "文件删除失败"),
    UNSUPPORTED_FILE_TYPE(1203, "不支持的文件类型"),
    FILE_SIZE_EXCEEDED(1204, "文件大小超出限制"),
    EMPTY_PICTURE(1205, "至少上传一张图片"),
    PICTURE_BROKEN(1206, "无法识别的图片格式或文件已损坏"),
    INVALID_FILE_TYPE(1207, "文件不是图片类型"),
    TOO_LARGE_FILE(1208, "图片大小超出上限，最大 20M"),
    FILE_URL_GENERATE_FAILED(1209, "文件 URL 生成失败"),
    INVALID_FILE_FORMAT(1210, "文件格式无效"),

    // 收藏夹相关 (1400-1499)
    REPEATED_FOLDER_NAME(1400, "收藏夹名称已存在"),
    NO_SUCH_FOLDER(1401, "收藏夹不存在或无权操作"),

    // 分类相关 (1500-1599)
    REPEATED_CATEGORY(1500, "当前分类已存在"),
    CATEGORY_NOT_FOUND(1501, "分类不存在"),

    // 系统错误 (2000-2099)
    INTERNAL_ERROR(2000, "服务器内部错误"),
    UNKNOWN_ERROR(2001, "系统未知错误"),
    SERVICE_UNAVAILABLE(2002, "服务暂时不可用"),
    TIMEOUT_ERROR(2003, "请求超时"),
    WRONG_OPERATION_TYPE(2004, "不支持的操作类型"),

    // 数据库相关 (2200-2299)
    DATA_NOT_FOUND(2200, "数据不存在"),
    DUPLICATE_KEY(2201, "数据库主键冲突"),
    DB_OPERATION_FAILED(2202, "数据库操作失败"),

    // 请求限制 (3000-3099)
    TOO_MANY_REQUESTS(3000, "请求过于频繁，请稍后重试"),
    API_DEPRECATED(3001, "该接口已废弃");

    private final int code;
    private final String message;
}
